Repository navigation
fix(update): delete bun lockfile before install - #591
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical issue affecting the reliability of Bun package updates. It introduces a preventative measure to ensure that the bun add -g command correctly fetches and installs the latest package versions by explicitly removing Bun's global lockfile prior to execution. This change prevents the lockfile from pinning older versions, thereby improving the consistency and success rate of updates. Highlights
Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request addresses an issue with bun's global lockfile not being updated by deleting it before installation. The approach is valid. My review includes a suggestion to improve the implementation by using asynchronous file operations and avoiding an inline require, which aligns better with the existing code style in the file.
|
|
||
| async function updateViaBun(channel: string): Promise<void> { | ||
| // Delete global lockfile — it pins old versions even with --force --no-cache | ||
| try { require("node:fs").unlinkSync(join(homedir(), ".bun", "install", "global", "bun.lock")); } catch { /* may not exist */ } |
There was a problem hiding this comment.
While this works, it's better to avoid inline require statements and use the imports already available at the top of the file. Since updateViaBun is an async function, you should use the asynchronous unlink from node:fs/promises instead of unlinkSync to avoid blocking the event loop. The unlink function is already imported in this file.
| try { require("node:fs").unlinkSync(join(homedir(), ".bun", "install", "global", "bun.lock")); } catch { /* may not exist */ } | |
| try { await unlink(join(homedir(), ".bun", "install", "global", "bun.lock")); } catch { /* may not exist */ } |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 59a6607560
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| async function updateViaBun(channel: string): Promise<void> { | ||
| // Delete global lockfile — it pins old versions even with --force --no-cache | ||
| try { require("node:fs").unlinkSync(join(homedir(), ".bun", "install", "global", "bun.lock")); } catch { /* may not exist */ } |
There was a problem hiding this comment.
Resolve bun lockfile path from BUN_INSTALL
This unlink targets only ~/.bun/install/global/bun.lock, but bun add -g uses the active environment and supports a custom global root via BUN_INSTALL; since runCommand forwards process.env, users with BUN_INSTALL set will keep using the lockfile in that alternate path, so the stale-version issue this change is trying to fix still reproduces for those installations.
Useful? React with 👍 / 👎.
bun's global lockfile pins old versions even with --force --no-cache. Delete it before installing.